/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.safetytask.utils;

public enum BusinessCode {
    SUCCESS(0,"success"),
    FAILURE(-1,"fail"),
    EXCEPTION(-2,"执行过程中发生异常"),
    NOT_LOGIN(10000,"没有登录，无法操作"),
    TASK_EMPTY_TASKNAME(620001,"任务标题不能为空"),
    TASK_EMPTY_TASKINITIATORCODE(620002,"任务发起人不能为空"),
    TASK_EMPTY_TASKRECEIVERCODE(620003,"任务接收人不能为空"),
    TASK_EMPTY_TASKDESCRIPTION(620004,"任务描述不能为空"),
    TASK_EMPTY_NOT_CHANGE_DATA(620005,"未选中数据"),
    TASK_EMPTY_DEL_NOT_CHANGE_DATA(620006,"未选中数据,无法删除"),
    TASKRESULT_EMPTY_TASKID(620007,"没有关联对应的任务"),
    TASKRESULT_EMPTY_ISDRAFT(620008,"提交状态为空"),
    TASKRESULT_TASK_NOT_FOUND(620009,"任务不存在"),
    TASKRESULT_EXCUTORCODE_NOT_AGREEMENT(620010,"任务指派的执行人不是当前登录用户，无法操作"),
    TASKRESULT_EXCUTORCODE_NOT_FOUND(620011,"任务执行人code为空"),
    TASKRESULT_TASKRESULT_NOT_FOUND(620012,"不存在对应的任务结果"),
    TASKRESULT_IS_COMMITED(620013,"任务结果已经提交,无法操作"),
    TASKRESULT_EMPTY_APPROVERCODE(620014,"任务结果审批人code为空"),
    TASKRESULT_TASK_RESULT_NOT_FOUND(620015,"任务结果不存在"),
    TASKRESULT_EMPTY_ISPASS(620016,"任务结果确认状态为空"),
    TASKRESULT_ILEAGEL_ISPASS(620017,"任务结果确认状态值不合法"),
    TASKRESULT_APPROVERCODE_NOT_AGREEMENT(620018,"任务指定的审批人与执行审批操作的人不一致"),
    TASKFOLLOW_EMPTY_FOLLOWCODE(620019,"关注人为空"),
    TASKFOLLOW_EMPTY_TASKID(620020,"关注的任务为空"),
    TASKFOLLOW_FOLLOW_NOT_FOUND(620021,"关注人不存在"),
    TASKFOLLOW_TASK_NOT_FOUND(620022,"关注的任务不存在"),
    TASKFOLLOW_TASK_IS_FOUND(620022,"该任务已关注了"),

    TASKFOLLOW_NOT_CHANGE_DATA(630001,"未选中数据"),
    ACCESS_DENY_NOT_USER(630002,"不是相关执行人"),
    DATA_REQUERED_MISSS(630003,"必须的填写的数据缺失"),
    USER_TASK(630004,"保存执行任务"),
    ;
    private final int code;
    private final String description;

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
    BusinessCode(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static BusinessCode valueOf(int value) {
        return switch (value) {
            case 0 -> SUCCESS;
            case -1 -> FAILURE;
            case -2 -> EXCEPTION;
            case 620001 -> TASK_EMPTY_TASKNAME;
            case 620002 -> TASK_EMPTY_TASKINITIATORCODE;
            case 620003 -> TASK_EMPTY_TASKRECEIVERCODE;
            case 620004 -> TASK_EMPTY_TASKDESCRIPTION;
            case 620005 -> TASK_EMPTY_NOT_CHANGE_DATA;
            case 620006 -> TASK_EMPTY_DEL_NOT_CHANGE_DATA;
            case 620007 -> TASKRESULT_EMPTY_TASKID;
            case 620008 -> TASKRESULT_EMPTY_ISDRAFT;
            case 620009 -> TASKRESULT_TASK_NOT_FOUND;
            case 620010 -> TASKRESULT_EXCUTORCODE_NOT_AGREEMENT;
            case 620011 -> TASKRESULT_EXCUTORCODE_NOT_FOUND;
            case 620012 -> TASKRESULT_TASKRESULT_NOT_FOUND;
            case 620013 -> TASKRESULT_EMPTY_APPROVERCODE;
            case 620014 -> TASKRESULT_EMPTY_APPROVERCODE;
            case 620015 -> TASKRESULT_TASK_RESULT_NOT_FOUND;
            case 620016 -> TASKRESULT_EMPTY_ISPASS;
            case 620017 -> TASKRESULT_ILEAGEL_ISPASS;
            case 620018 -> TASKRESULT_APPROVERCODE_NOT_AGREEMENT;
            case 620019 -> TASKFOLLOW_EMPTY_FOLLOWCODE;
            case 620020 -> TASKFOLLOW_EMPTY_TASKID;
            case 620021 -> TASKFOLLOW_FOLLOW_NOT_FOUND;
            case 620022 -> TASKFOLLOW_TASK_NOT_FOUND;
            case 630001 -> TASKFOLLOW_NOT_CHANGE_DATA;
            default -> null;
        };
    }
}
